package com.link.base.base.consumer.controller;

import com.link.base.base.consumer.model.PortalAccntTag;
import com.link.base.base.consumer.service.PortalAccntTagService;
import com.link.base.user.model.CoreUser;
import com.link.core.basic.controller.BasicController;
import com.link.core.basic.service.BasicService;
import com.link.core.util.UserUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
/**
 * 客户关联标签相关服务
 * @author  yipeng.zhu@hand-china.com
 * @date:   2018/11/2 16:21
 * @version 1.0
 */

@Controller
@RequestMapping("/link/accntTags")
public class AccountTagController extends BasicController<PortalAccntTag> {
    @Resource
    private PortalAccntTagService portalAccntTagService;

    @Override
    public BasicService<PortalAccntTag> getBasicService() throws Exception {
        return portalAccntTagService;
    }

    @Override
    public void beforInsert(PortalAccntTag entity, HttpServletRequest request) throws Exception {
        CoreUser landedUser = UserUtil.getUser();
        if (landedUser == null) {
            entity.setId(0L);
        } else {
            entity.setOrgId(landedUser.getOrgId());
        }
    }
}
